package com.jasonchoi.redisqueue.pubsub.pub;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

/**
 * Redis消息队列-发送者
 * @Author: JasonChoi
 * @Date: 2020/3/13 15:34
 */
@Component
public class CustomRedisSender {

    public static final String CHANNEL_RECEIVETEST = "CHANNEL_RECEIVETEST";

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    public void sendMessage(String message){
        try {
            stringRedisTemplate.convertAndSend(CHANNEL_RECEIVETEST, message);
        }catch (Exception e){
            e.printStackTrace();
        }
    }




}
